Public Class DSearch

    Public Shared Function GetMasetrSearchs() As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT SearchNo,SearchName,FromClause,WhereClause,OrderClause FROM mSearch WHERE Status='A' ORDER BY SearchName")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetMasetrSearchs")
        End Try
    End Function

    Public Shared Function GetSearchItems(ByVal ItemNo As String) As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT ItemDbName,ItemCaption,ItemDataType,UseFrom,CodeId FROM mSearchItems WHERE ForSearch='y' AND SearchNo=" & ItemNo.ToString() & " ORDER BY SeqNo")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetSearchItems")
        End Try
    End Function

    Public Shared Function GetDisplayItems(ByVal ItemNo As String) As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT ItemDbName,ItemCaption,ItemDataType,SeqNo,DisplayName FROM mSearchItems WHERE SearchNo=" & ItemNo.ToString() & " ORDER BY SeqNo")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetDisplayItems")
        End Try
    End Function

    Public Shared Function GetFromOperators() As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT CodeID,CodeDesc FROM MMISCCD WHERE CodeType='OPTR' OR CodeType='OPTRF' AND Status='A'")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetFromOperators")
        End Try
    End Function

    Public Shared Function GetOperators() As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT CodeID,CodeDesc FROM MMISCCD WHERE CodeType='OPTR' AND Status='A'")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetOperators")
        End Try
    End Function

    Public Shared Function GetAllOperators() As DataTable
        Try
            Return DbHelper.ExecuteDataTable("SELECT CodeID,CodeDesc FROM MMISCCD WHERE CodeType='OPTRA' AND Status='A'")
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetAllOperators")
        End Try
    End Function

    Public Shared Function GetResults(ByVal Sql As String) As DataTable
        Try
            Return DbHelper.ExecuteDataTable(Sql)
        Catch ex As Exception
            Return Nothing
            DGeneral.ErrorHandler(ex.Message, "DAL", "Dscheme", "GetResults")
        End Try
    End Function
End Class
